﻿using Jira;
using JiraPresentation;
using NUnit.Framework;

namespace Tests
{
    [TestFixture]
    public sealed class JsonTests
    {
        [Test]
        public void TryPopulateSucceedsTest([Values(
            //PP-1261:
@"{
  ""MethodTypeName"": ""N/A"",
  ""MethodName"": ""N/A"",
  ""Exceptions"": []
}",
            //PP-1261:
            //previously SOC-1915 and SOC-1966 added in commits 146313 and 146315 anti-respectively were our test cases for starting with a '.'
            //However, they don't really start with a '.', there was an issue at the time where the first character was ignored.
            //This was fixed and PP-1261 is its regression test.
            //So this is a modification of PP-1261 so that we still have a test case that starts with a '.'
@".
{
  ""MethodTypeName"": ""N/A"",
  ""MethodName"": ""N/A"",
  ""Exceptions"": []
}",
            //SA-348:
@"{
  ExceptionTypeName: ""System.IndexOutOfRangeException"",
  MethodTypeName: ""[SmartAssembly]SmartAssembly.Project"",
  MethodName: ""public void Prepare(Configuration configuration, ProjectPreparingFeedbackEventHandler feedback);"",
  ExceptionMessage: ""Index was outside the bounds of the array."",
  SourceCode: ""http://wwwcode.red-gate.com/source/xref/SmartAssembly_Trunk/Source/SmartAssembly/Project.cs?r=%7b2010-06-03T15:34:13Z%7d#4257"",
  StackTrace: [
    ""System.IndexOutOfRangeException: Index was outside the bounds of the array."",
    ""at [SmartAssembly]SmartAssembly.Project, public void Prepare(Configuration configuration, ProjectPreparingFeedbackEventHandler feedback);:4257"",
    ""at [SmartAssembly]SmartAssembly.Configuration, public void Prepare(ProjectPreparingFeedbackEventHandler feedback);:2225"",
    ""System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation."",
    ""at [SmartAssembly]SmartAssembly.UI.Controls.AfterBuildFailed, internal void OnItemClick(SmartItemClickEventArgs e);:35"",
    ""at [Xceed.SmartUI]Xceed.SmartUI.SmartControl, internal void InvokeItemClick(SmartItem item, ClickSource clickSource);:"",
    ""at [Xceed.SmartUI]Xceed.SmartUI.SmartControl, internal void OnMouseUp(MouseEventArgs e);:"",
    ""at [SmartAssembly]SmartAssembly.UI.Controls.SmartPanel, internal void WndProc(Message& m);:4402"",
    """"
  ]
}",
            //SA-350:
@"{
  ExceptionTypeName: ""[SmartAssembly]SmartAssembly.PleaseRetryAndReportThisException"",
  MethodTypeName: ""[SmartAssembly]SmartAssembly.IL.Module"",
  MethodName: ""private void Parse();"",
  ExceptionMessage: ""OutOfMemoryException"",
  SourceCode: ""http://wwwcode.red-gate.com/source/xref/SmartAssembly_Trunk/Source/SmartAssembly/IL/Module.cs?r=%7b2010-06-03T15:34:13Z%7d#5971"",
  StackTrace: [
    ""[SmartAssembly]SmartAssembly.PleaseRetryAndReportThisException: OutOfMemoryException"",
    ""at [SmartAssembly]SmartAssembly.IL.Module, private void Parse();:5971"",
    ""at [SmartAssembly]SmartAssembly.IL.Module, internal Module(Assembly owner, string fileName);:6702"",
    ""at [SmartAssembly]SmartAssembly.IL.Assembly, public Assembly(string assemblyFileName);:1001"",
    ""at [SmartAssembly]SmartAssembly.Project, private void LoadDependency(Assembly parentAssembly, string dependencyFullName, Configuration configuration, string[] dependenciesTree, ProjectAnalysingFeedbackEventHandler feedback);:709"",
    ""at [SmartAssembly]SmartAssembly.Project, private void LoadDependency(Assembly parentAssembly, string dependencyFullName, Configuration configuration, string[] dependenciesTree, ProjectAnalysingFeedbackEventHandler feedback);:782"",
    ""at [SmartAssembly]SmartAssembly.Project, public void LoadAssemblyAndDependencies(Configuration configuration, ProjectAnalysingFeedbackEventHandler feedback);:877"",
    ""at [SmartAssembly]SmartAssembly.Configuration, public void LoadAssemblyAndDependencies(ProjectAnalysingFeedbackEventHandler feedback);:2197"",
    ""at [SmartAssembly]SmartAssembly.UI.Controls.ProjectSettings, internal void OnCheckedChanged(object sender, CheckedChangedEventArgs e);:2825"",
    ""at [SmartAssembly]SmartAssembly.UI.Controls.SmartPanel, internal void InvokeCheckedChanged(CheckedChangedEventArgs e);:3748"",
    ""at [SmartAssembly]SmartAssembly.UI.Controls.SmartPanel/CheckBox, internal void OnCheckedChanged(CheckedChangedEventArgs e);:1879"",
    ""at [SmartAssembly]SmartAssembly.UI.Controls.SmartPanel/Option, internal void OnCheckedChanged(CheckedChangedEventArgs e);:2213"",
    ""at [SmartAssembly]SmartAssembly.UI.Controls.SmartPanel/CheckBox, public void set_Checked(bool value);:1872"",
    ""at [SmartAssembly]SmartAssembly.UI.Controls.SmartPanel/Option, internal void OnClick(SmartItemClickEventArgs e);:2158"",
    ""at [Xceed.SmartUI]Xceed.SmartUI.SmartItem, internal void InvokeOnClick(SmartItemClickEventArgs e);:"",
    ""at [Xceed.SmartUI]Xceed.SmartUI.SmartControl, internal void InvokeItemClick(SmartItem item, ClickSource clickSource);:"",
    ""at [Xceed.SmartUI]Xceed.SmartUI.SmartControl, internal void OnMouseUp(MouseEventArgs e);:"",
    ""at [SmartAssembly]SmartAssembly.UI.Controls.SmartPanel, internal void WndProc(Message& m);:4402"",
    """"
  ]
}",
            //SOC-1307:
@"{
  ""MethodTypeName"": ""[RedGate.SQLCompare.Engine]RedGate.SQLCompare.Engine.ReadFromFolder.DatabaseFromFolderFactory"",
  ""MethodName"": ""private void ProcessFile(FileInfo file);"",
  ""Exceptions"": [
    {
      ""ExceptionTypeName"": ""[RedGate.SQLCompare.ASTParser]antlr.NoViableAltException"",
      ""ExceptionMessage"": ""unexpected token: [\""2087541.91634113\"",<775>,line=16,col=120] [char=795]"",
      ""StackTrace"": [
        ""at RedGate.SQLCompare.ASTParser.StructureParser.spatialIndexSubOption()"",
        "" at RedGate.SQLCompare.ASTParser.StructureParser.spatialIndexSubOptionList()"",
        "" at RedGate.SQLCompare.ASTParser.StructureParser.spatialIndexOption()"",
        "" at RedGate.SQLCompare.ASTParser.StructureParser.spatialIndexOptionList()"",
        "" at RedGate.SQLCompare.ASTParser.StructureParser.createSpatialIndexStatement()"",
        "" at RedGate.SQLCompare.ASTParser.StructureParser.createStatement()"",
        "" at RedGate.SQLCompare.ASTParser.StructureParser.statementFirstInBatch()""
      ]
    },
    {
      ""ExceptionTypeName"": ""[RedGate.SQLCompare.Engine]RedGate.SQLCompare.Engine.ReadFromFolder.ErrorsOccuredDuringScriptFileParsingException"",
      ""ExceptionMessage"": ""Errors occured whilst parsing file C:\\Users\\matt clepper\\AppData\\Local\\Red Gate\\SQL Source Control 1\\WorkingBases\\2rvsqfkq.st2\\Tables\\dbo.JohnstonCountyAddressPoints.sql\r\n'2087541.91634113' at line 16"",
      ""StackTrace"": [
        ""at [RedGate.SQLCompare.Engine]RedGate.SQLCompare.Engine.ReadFromFolder.DatabaseFromFolderFactory, private void ProcessFile(FileInfo file);:3914"",
        ""at [RedGate.SQLCompare.Engine]RedGate.SQLCompare.Engine.ReadFromFolder.DatabaseFromFolderFactory, internal void Populate();:521"",
        ""at [RedGate.SQLCompare.Engine]RedGate.SQLCompare.Engine.Database, public void Register(string path, ScriptDatabaseInformation dbinfo, Options options);:2035"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.Memoization.ScriptFolderRegisterMemoizer/<>c__DisplayClass1, public void <RegisterDb>b__0();:39"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.CompareEngineUtils, private static void DoActionWithCancel(ICancellableOperationStatus status, ICancellable database, Action action);:52"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.CompareEngineUtils/<>c__DisplayClass7, public void <DoWrappedActionWithCancel>b__6();:79"",
        "" at RedGate.SQLSourceControl.Engine.CompareEngineUtils.DoWrapped(Action action)""
      ]
    },
    {
      ""ExceptionTypeName"": ""[RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.ErrorsOccuredDuringScriptFileParsingException"",
      ""ExceptionMessage"": ""Errors occured whilst parsing file C:\\Users\\matt clepper\\AppData\\Local\\Red Gate\\SQL Source Control 1\\WorkingBases\\2rvsqfkq.st2\\Tables\\dbo.JohnstonCountyAddressPoints.sql\r\n'2087541.91634113' at line 16"",
      ""SourceCode"": ""http://wwwcode.red-gate.com/source/xref/SQLSourceControl_1.0.1_RC/Source/Engine/CompareEngineUtils.cs?a=true&r=%7b2010-06-24T14:29:50Z%7d#36"",
      ""StackTrace"": [
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.CompareEngineUtils, internal static void DoWrapped(Action action);:36"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.CompareEngineUtils, internal static void DoWrappedActionWithCancel(ICancellableOperationStatus status, ICancellable database, Action action);:80"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.Memoization.ScriptFolderRegisterMemoizer, private static Database RegisterDb(string path, ScriptRegisterArguments args);:38"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.Memoization.IOMemoizer`2, internal Handle`1<!1> GetMemoized(string path, !0 argument);:38"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.Memoization.ScriptFolderRegisterMemoizer, public Handle`1<class [RedGate.SQLCompare.Engine]RedGate.SQLCompare.Engine.Database> GetRegistered(string path, ScriptDatabaseInformation folderOptions, Options options, ICancellableOperationStatus status);:18"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.ThreeWayDiffBuilder/<>c__DisplayClassd`1/<>c__DisplayClass12, public void <BuildADiff>b__8();:185"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.Cancellables.CancellableOperation/<>c__DisplayClass9, public void <DoInParallel>b__6();:170"",
        "" at RedGate.SQLSourceControl.Engine.Cancellables.CancellableOperation..<>c__DisplayClass9.<DoInParallel>b__6()"",
        "" at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)"",
        "" at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)"",
        "" at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)"",
        ""Exception rethrown at [0]: "",
        "" at System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg, Boolean bProxyCase)"",
        "" at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData)"",
        "" at RedGate.SQLSourceControl.Engine.Action.EndInvoke(IAsyncResult result)"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.Cancellables.CancellableOperation, internal static void DoInParallel(ICancellableOperationStatus status, Pair`2<System.String><class [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.Action>[] labelledActions);:222"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.ThreeWayDiffBuilder/<>c__DisplayClassd`1, public !0 <BuildADiff>b__7();:276"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.CompareEngineUtils/<>c__DisplayClassd`1, public void <DoFuncWithCancel>b__c();:92"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.CompareEngineUtils, private static void DoActionWithCancel(ICancellableOperationStatus status, ICancellable database, Action action);:52"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.CompareEngineUtils, internal static !!0 DoFuncWithCancel(ICancellableOperationStatus status, ICancellable database, Func`1<!!0> function);:92"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.ThreeWayDiffBuilder, private !!0 BuildADiff(ICancellableOperationStatus status, IReadOnlySourceControlServerCallBacks sourceControlUserCallBacks, ScriptDatabaseInformation folderOptions);:152"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.ThreeWayDiffBuilder/<>c__DisplayClass4, public ThreeWayDiff <BuildWithNoopResolution>b__3();:66"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.ThreeWayDiffBuilder, private !!0 BuildSafe(ICancellableOperationStatus status, Func`1<!!0> innerBuild);:113"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.ThreeWayDiffBuilder, public ThreeWayDiff BuildWithNoopResolution(ICancellableOperationStatus status, IReadOnlySourceControlServerCallBacks sourceControlUserCallBacks, ScriptDatabaseInformation folderOptions);:55"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.BoundDatabase, private ThreeWayDiff GetThreeWayDiff(ICancellableOperationStatus status, IReadOnlySourceControlServerCallBacks sourceControlUserCallBacks);:122"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.BoundDatabase, private ToCommitChangeSet GetNewCommitableChanges(ICancellableOperationStatus status, IReadOnlySourceControlServerCallBacks sourceControlUserCallBacks);:101"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.BoundDatabase/<>c__DisplayClass2, public ToCommitChangeSet <GetCancellableCommitableChanges>b__1(ICancellableOperationStatus status);:148"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.Cancellables.MutexedCancellableOperation`1/<>c__DisplayClass1, public void <Invoke>b__0();:68"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.Cancellables.CancellableOperationBase, internal void InvokeWithTracker(Action action);:78"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.Cancellables.MutexedCancellableOperation`1, public !0 Invoke();:61"",
        ""at [RedGate.SQLSourceControl.CommonUI]RedGate.SQLSourceControl.CommonUI.Controls.CancellableOperationPostProcesser`2, public !1 Invoke();:33"",
        ""at [RedGate.SQLSourceControl.CommonUI]RedGate.SQLSourceControl.CommonUI.Controls.CancellableControl`2/<>c__DisplayClassa, public void <InvokeOperation>b__8();:176"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SmartAssembly.ExceptionReporting.ErrorReporterBase, private void Do(Action toDo, Predicate`1<class [mscorlib]System.Exception> shouldReportPredicate, bool rethrow);:59"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SmartAssembly.ExceptionReporting.ErrorReporterBase, public void DoWithObviousExceptionsRethrowAll(Action action);:73"",
        ""at [RedGate.SQLSourceControl.CommonUI]RedGate.SQLSourceControl.CommonUI.Forms.ErrorDialog, public static void DoWithObviousExceptionsRethrowAll(Action action);:127"",
        "" at RedGate.SQLSourceControl.CommonUI.Controls.CancellableControl`2.InvokeOperation(ICancellableOperation`1 operation, Object token)""
      ]
    }
  ]
}",
            //SOC-1812:
@"When trying to link to a vault server, if you specify // as the server and provide valid repository name e.g. one and source control folder e.g $/bob and click Link you get an Invalid URI exception

Steps
1. Install SoC (1.0.8.90) and open it in SSMS
2. Select a database in SSMS and click the create new link to source control
3. Select Vault
4. In the server field enter //
5. Enter a repository name e.g one
6. Enter a source control folder location e.g $/bob and click Link

{
  ""MethodTypeName"": ""[RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.UriUtils"",
  ""MethodName"": ""internal static Uri GetCannonUri(string uri);"",
  ""Exceptions"": [
    {
      ""ExceptionTypeName"": ""[System]System.UriFormatException"",
      ""ExceptionMessage"": ""Invalid URI: The hostname could not be parsed."",
      ""SourceCode"": ""http://wwwcode.red-gate.com/source/xref/SQLSourceControl_VaultAndVssSupport/Source/Engine/SrcC/UriUtils.cs?a=true&r=%7b2010-11-15T15:36:17Z%7d#19"",
      ""StackTrace"": [
        ""at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)"",
        "" at System.Uri..ctor(String uriString)"",
        "" at System.UriBuilder..ctor(String uri)"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.UriUtils, internal static Uri GetCannonUri(string uri);:19"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.Vault.VaultLocation, public VaultLocation(string serverUrl, string repository, string folder);:64"",
        ""at [RedGate.SQLSourceControl.CommonUI]RedGate.SQLSourceControl.CommonUI.Controls.VaultLocationControl, public bool TryGetChosenSrcCLocation(ISrcCLocation& location);:80"",
        ""at [RedGate.SQLSourceControl.CommonUI]RedGate.SQLSourceControl.CommonUI.Controls.SourceControlLocationControl, public bool TryGetChosenSrcCLocation(ISrcCLocation& location);:91"",
        ""at [RedGate.SQLSourceControl.CommonUI]RedGate.SQLSourceControl.CommonUI.Forms.DatabaseToSourceControlForm, private void <AcceptButton_Click>b__0();:65"",
        "" at RedGate.SQLSourceControl.Engine.SmartAssembly.ExceptionReporting.ErrorReporterBase.Do(Action , Predicate`1 , Boolean )""
      ]
    }
  ]
}",
            //SOC-1915:
@"1. Db1: Turned off permissions to view definition for Simple user
2. Db1: Committed change to the user
3. Db2: Attempted to commit data <<< Commit failed, out of date message
4. Db1: Turned on View Definition for Simple user
5. Db2: Nav to Get Latest tab <<< Incoming user change and Data for Table_1 in conflict
6. Db2. Commit tab shows Table_1 in conflict -> Keep Mine and Commit <<< Nothing to commit error


{
  ""MethodTypeName"": ""[RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.Svn.SvnWorkspaceOperations/<>c__DisplayClass43/<>c__DisplayClass45"",
  ""MethodName"": ""public void <Commit>b__40();"",
  ""Exceptions"": [
    {
      ""ExceptionTypeName"": ""[RedGate.Shared.Utils]RedGate.Shared.Utils.InvalidStateException"",
      ""ExceptionMessage"": ""Nothing to commit"",
      ""SourceCode"": ""http://wwwcode.red-gate.com/source/xref/SQLSourceControl_2.0.0_EA1/Source/Engine/SrcC/Svn/SvnWorkspaceOperations.cs?a=true&r=%7b2010-11-29T13:30:19Z%7d#795"",
      ""StackTrace"": [
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.Svn.SvnWorkspaceOperations/<>c__DisplayClass43/<>c__DisplayClass45, public void <Commit>b__40();:795"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.Svn.SvnExceptionRewriter, internal static void RunWithConvertException(Action action, SscContextType context);:36"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.Svn.SvnClientUtils, private static void WithSvnClient(Action action, object svnClientLock, Func`1<class [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.Svn.SvnReadOnlyAuthenticationWrapper> wrapperFactory, SscContextType context);:30"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.Svn.SvnClientUtils, internal static void WithSvnClient(ICancellableOperationStatus status, ISourceControlUserCallBacks callBacks, Action action, SvnLocation projectRoot, SvnClient svnClient, object svnClientLock);:10"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.Svn.SvnWorkspaceOperations, private void WithSvnClient(ICancellableOperationStatus status, ISourceControlUserCallBacks callBacks, Action action);:935"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.Svn.SvnWorkspaceOperations/<>c__DisplayClass43, public void <Commit>b__3f(ICancellableOperationStatus status);:762"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.Cancellables.CancellableOperation, private void <Invoke>b__0();:128"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.Cancellables.CancellableOperationBase, internal void InvokeWithTracker(Action action);:78"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.Cancellables.CancellableOperation, public void Invoke();:99"",
        "" at RedGate.SQLSourceControl.Engine.SmartAssembly.ExceptionReporting.ErrorReporterBase.Do(Action , Predicate`1 , Boolean )""
      ]
    }
  ]
}",
            //SOC-1934:
@"If you link to a location in vault and then the source control folder is moved, so you unlink and re link to it via source control you get the below error.

Steps.
1. Link to a location in source control
2. Move/rename the source control folder
3. Unlink and relink via source control
4. Select Show history on the database.

{
  ""MethodTypeName"": ""[RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.Vault.VaultWorkspaceOperations"",
  ""MethodName"": ""private static long InnerGetFolderVersionForTxDate(ClientInstance client, VaultDateTime txDate, string projectRoot);"",
  ""Exceptions"": [
    {
      ""ExceptionTypeName"": ""System.NullReferenceException"",
      ""ExceptionMessage"": ""Object reference not set to an instance of an object."",
      ""StackTrace"": [
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.Vault.VaultWorkspaceOperations, private static long InnerGetFolderVersionForTxDate(ClientInstance client, VaultDateTime txDate, string projectRoot);:612"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.Vault.VaultWorkspaceOperations, internal static long GetFolderVersionForTxDate(ClientInstance client, VaultDateTime txDate, string projectRoot);:599"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.Vault.VaultRemoteOperations/<>c__DisplayClass26, public void <GetHistory>b__25();:295"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.Vault.VaultClientUtils/<>c__DisplayClass3, public void <WithVaultClient>b__1();:35"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.Vault.VaultClientUtils, private static void WithWorkingFolderSet(ClientInstance client, VaultLocation projectRoot, string rootPath, Action action);:164"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.Vault.VaultClientUtils/<>c__DisplayClass3, public void <WithVaultClient>b__0();:33"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.Vault.VaultExceptionRewriter, public static void RunWithConvertException(Action action);:22"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.Vault.VaultClientUtils, public static void WithVaultClient(ICancellableOperationStatus status, IReadOnlySourceControlServerCallBacks callBacks, Action action, ClientInstance client, object clientLock, VaultLocation projectRoot, string rootPath);:24"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.Vault.VaultRemoteOperations, private void WithVaultClient(ICancellableOperationStatus status, IReadOnlySourceControlServerCallBacks callBacks, Action action);:355"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.Vault.VaultRemoteOperations, public IHistoryEntries GetHistory(ICancellableOperationStatus status, Pair`2<System.String><System.Int64> subpath, IReadOnlySourceControlServerCallBacks callbacks);:258"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.BoundDatabase/<>c__DisplayClassd, public SqlHistoryEntries <GetHistory>b__c();:179"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.DisposableUtils, public static !!0 GetOrDispose(IDisposable toDisposeOnFailure, Func`1<!!0> action);:27"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.BoundDatabase, private IHistoryEntries GetHistory(ICancellableOperationStatus status, IDatabaseThingSet thingSet, IReadOnlySourceControlServerCallBacks callbacks);:178"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.BoundDatabase/<>c__DisplayClassa, public IHistoryEntries <GetCancellableHistory>b__9(ICancellableOperationStatus status);:156"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.Cancellables.MutexedCancellableOperation`1/<>c__DisplayClass5, public void <Invoke>b__4();:55"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.Cancellables.CancellableOperationBase, internal void InvokeWithTracker(Action action);:78"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.Cancellables.MutexedCancellableOperation`1, public !0 Invoke();:48"",
        ""at [RedGate.SQLSourceControl.CommonUI]RedGate.SQLSourceControl.CommonUI.Controls.CancellableControl`2/<>c__DisplayClassa, public void <InvokeOperation>b__8();:184"",
        "" at RedGate.SQLSourceControl.Engine.SmartAssembly.ExceptionReporting.ErrorReporterBase.Do(Action , Predicate`1 , Boolean )""
      ]
    }
  ]
}",
            //SOC-1966:
@"1. Attempt to create a Eval repository on behemoth.test\sql2005cs db called 'SOC_DatabasePollingResults_24601208_7318_4262_8410_21a60874fcbd_₡₢₣₤₥₦₧₨₩₪₫€₭₮₯₰_one two_foo [ bar_dog ] cat_sql ' dev_the "" lol'

Second test case:

'Create' button is still enabled in some white-space character scenarios

1. Launch dialog to create the eval repository
2. Delete the contents if a db name appears
3. Tap the space bar <<< Create button is still enabled
4. Click the Create button


{
  ""MethodTypeName"": ""[RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.Evaluation.EvaluationRepositoryProvider"",
  ""MethodName"": ""internal static EvaluationRepository CreateNewEvaluationRepository(string repositoryName);"",
  ""Exceptions"": [
    {
      ""ExceptionTypeName"": ""[SharpSvn]SharpSvn.SvnException"",
      ""ExceptionMessage"": ""unable to open database file"",
      ""SourceCode"": ""http://wwwcode.red-gate.com/source/xref/SQLSourceControl_Trunk/Source/Engine/SrcC/Evaluation/EvaluationRepositoryProvider.cs?a=true&r=%7b2010-12-07T20:15:09Z%7d#34"",
      ""StackTrace"": [
        ""at SharpSvn.SvnClientArgs.HandleResult(SvnClientContext client, SvnException error)"",
        "" at SharpSvn.SvnClientArgs.HandleResult(SvnClientContext client, svn_error_t* error)"",
        "" at SharpSvn.SvnRepositoryClient.CreateRepository(String repositoryPath, SvnCreateRepositoryArgs args)"",
        "" at SharpSvn.SvnRepositoryClient.CreateRepository(String repositoryPath)"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.SrcC.Evaluation.EvaluationRepositoryProvider, internal static EvaluationRepository CreateNewEvaluationRepository(string repositoryName);:34"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.Controller, public EvaluationRepository CreateEvaluationRepository(string repositoryName);:202"",
        ""at [RedGate.SQLSourceControl.CommonUI]RedGate.SQLSourceControl.CommonUI.ViewController, public EvaluationRepository CreateEvaluationRepository(string repositoryName);:219"",
        ""at [RedGate.SQLSourceControl.CommonUI]RedGate.SQLSourceControl.CommonUI.Forms.CreateNewEvaluationRepositoryForm, private void <m_CreateButton_Click>b__0();:52"",
        "" at RedGate.SQLSourceControl.Engine.SmartAssembly.ExceptionReporting.ErrorReporterBase.Do(Action , Predicate`1 , Boolean )""
      ]
    }
  ]
}",
            //SOC-2131:
@"To reproduce;

1) Create DB1
2) Link to source control
3) Execute the following query:

CREATE TABLE Counties
(
	Id INT IDENTITY PRIMARY KEY,
	NAME VARCHAR(32)
)
GO
INSERT INTO dbo.Counties ( NAME ) VALUES ('Cork') INSERT INTO dbo.Counties ( NAME ) VALUES ('Galway')

4) Select the table for static data
5) Commit both schema and data
6) Create DB2
7) Execute the following query:

CREATE TABLE counties
(
	Id INT IDENTITY PRIMARY KEY,
	NAME VARCHAR(32)
)
GO
INSERT INTO dbo.counties ( NAME ) VALUES ('Mayo') INSERT INTO dbo.counties ( NAME ) VALUES ('Donegal')

8) Link to source control
9) Visit the Get Latest tab. <- It should SA here if you are using the EA, mine didn't due to a bug in atomic schema/data commits
10) Select counties tables for source controlling static data
11) Visit the Get Latest tab <- It should definitely SA here.

{
  ""MethodTypeName"": ""[RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.DiffBuilding.TableDifferenceProtoDifference"",
  ""MethodName"": ""internal TableDifferenceProtoDifference(TableDifference tableDifference);"",
  ""Exceptions"": [
    {
      ""ExceptionTypeName"": ""[RedGate.Shared.Utils]RedGate.Shared.Utils.InvalidStateException"",
      ""ExceptionMessage"": ""Owners must match\r\n Expected dashboard actual Dashboard"",
      ""SourceCode"": ""http://wwwcode.red-gate.com/source/xref/SQLSourceControl_2.0.2_EA3/Source/Engine/DiffBuilding/TableDifferenceProtoDifference.cs?a=true&r=%7b2011-01-21T12:38:56Z%7d#26"",
      ""StackTrace"": [
        ""at RedGate.Shared.Utils.Aver.Equals[T](T expected, T actual, String message)"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.DiffBuilding.TableDifferenceProtoDifference, internal TableDifferenceProtoDifference(TableDifference tableDifference);:26"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.DiffBuilder/TwoWayDiffBuildSession, private static IProtoDifference <IndexTableDifferencesToIProtoDifferences>b__10(TableDifference diff);:336"",
        ""   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)"",
        ""   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector)"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.DiffBuilder/TwoWayDiffBuildSession, private DatabaseObjectIdDictionary`1<!!0> IndexTableDifferences(IEnumerable`1<class [RedGate.SQLDataCompare.Engine]RedGate.SQLDataCompare.Engine.TableDifference> differences, Predicate`1<class [RedGate.SQLDataCompare.Engine]RedGate.SQLDataCompare.Engine.TableDifference> predicate, Func`2<class [RedGate.SQLDataCompare.Engine]RedGate.SQLDataCompare.Engine.TableDifference><!!0> elementSelector);:346"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.DiffBuilder/TwoWayDiffBuildSession, private DatabaseObjectIdDictionary`1<class [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.DiffBuilding.IProtoDifference> IndexTableDifferencesToIProtoDifferences(IEnumerable`1<class [RedGate.SQLDataCompare.Engine]RedGate.SQLDataCompare.Engine.TableDifference> differences, Predicate`1<class [RedGate.SQLDataCompare.Engine]RedGate.SQLDataCompare.Engine.TableDifference> predicate);:336"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.DiffBuilder/TwoWayDiffBuildSession, internal DatabaseObjectIdDictionary`1<class [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.DiffBuilding.IProtoDifference> IndexTableDifferencesLiveToWorkingBase(IEnumerable`1<class [RedGate.SQLDataCompare.Engine]RedGate.SQLDataCompare.Engine.TableDifference> differences, SourceControlOperation operation);:325"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.DiffBuilder/ThreeWayDiffBuildSession, internal void CompareWorkspaces(SourceControlOperation operation);:181"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.DiffBuilder/TwoWayDiffBuildSession, internal void BuildCommon(SourceControlOperation operation);:122"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.DiffBuilder/ThreeWayDiffBuildSession, internal bool TryBuildToCommitChangeSet(ToCommitChangeSet&  toCommitChangeSet);:67"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.DiffBuilder, private !!0 WrapThreeWayDiffBuildSession(Func`2<class [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.DiffBuilder/ThreeWayDiffBuildSession><class [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.DiffBuilder/TryGetter`1<!!0>> tryGetterGenerator, ICancellableOperationStatus status, IReadOnlySourceControlServerCallBacks callBacks);:106"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.DiffBuilder, internal ToCommitChangeSet BuildToCommitChangeSet(ICancellableOperationStatus status, IReadOnlySourceControlServerCallBacks callBacks);:72"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.BoundDatabase, private ToCommitChangeSet GetNewCommitableChanges(ICancellableOperationStatus status, IReadOnlySourceControlServerCallBacks sourceControlUserCallBacks);:107"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.BoundDatabase/<>c__DisplayClass1, public ToCommitChangeSet <GetCancellableCommitableChanges>b__0(ICancellableOperationStatus status);:128"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.Cancellables.MutexedCancellableOperation`1/<>c__DisplayClass5, public void <Invoke>b__4();:55"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.Cancellables.CancellableOperationBase, internal void InvokeWithTracker(Action action);:78"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.Cancellables.MutexedCancellableOperation`1, public !0 Invoke();:48"",
        ""at [RedGate.SQLSourceControl.Engine]RedGate.SQLSourceControl.Engine.Cancellables.CancellableOperationPostProcesser`2, public !1 Invoke();:22"",
        ""at [RedGate.SQLSourceControl.CommonUI]RedGate.SQLSourceControl.CommonUI.Controls.CancellableControl`2/<>c__DisplayClassa, public void <InvokeOperation>b__8();:187"",
        ""   at RedGate.SQLSourceControl.Engine.SmartAssembly.ExceptionReporting.ErrorReporterBase.Do(Action , Predicate`1 , Boolean )""
      ]
    }
  ]
}"
            )] string serializedPropertyBag)
        {
            BugDescription bugDescription;
            Assert.True(JiraJsonSerializer.TryPopulate(serializedPropertyBag, out bugDescription));
            Assert.NotNull(bugDescription);
        }

        [Test]
        public void TryPopulateFailsTest([Values(
            //SOC-1337:
@"The engine tests create a multi-line comment when doing a SscEngineTestMethods.CommitAll.

The method automatically appends other lines to the single line comment supplied by the calling code.

However, if the comment supplied by the calling code finishes with a workitem 'magic' token, then the commit fails because SOC ignores the fact that there is a /r/n after the workitem token, and appends the first word of the second line to it, therefore making the workitem id invalid.

This is not an issue within the product at the moment because we cannot enter multi-line comments. "
            )] string serializedPropertyBag)
        {
            BugDescription bugDescription;
            Assert.False(JiraJsonSerializer.TryPopulate(serializedPropertyBag, out bugDescription));
            Assert.Null(bugDescription);
        }
    }
}
